package org.linlinjava.litemall.db.service;

        import javax.annotation.Resource;

        import org.linlinjava.litemall.db.dao.LitemallUserHerbAuthMapper;
        import org.linlinjava.litemall.db.domain.*;
        import org.springframework.stereotype.Service;
        import org.springframework.util.StringUtils;

        import java.time.LocalDateTime;
        import java.util.List;

@Service
public class LitemallUserHerbAuthService {
    @Resource
    private LitemallUserHerbAuthMapper userHerbAuthMapper;

    public List<LitemallUserHerbAuth> queryList(String shopId) {
        LitemallUserHerbAuthExample example = new LitemallUserHerbAuthExample();
        LitemallUserHerbAuthExample.Criteria criteria = example.createCriteria();

        if (!StringUtils.isEmpty(shopId)) {
            criteria.andShopIdEqualTo(Integer.valueOf(shopId));
        }

        return userHerbAuthMapper.selectByExample(example);
    }

    public void delete(LitemallUserHerbAuth userHerbApprove) {
        userHerbApprove.setUpdateTime(LocalDateTime.now());
        userHerbApprove.setDeleted(true);
        userHerbAuthMapper.updateByPrimaryKeySelective(userHerbApprove);
    }

    public void add(LitemallUserHerbAuth userHerbApprove) {
        userHerbApprove.setId((int)System.currentTimeMillis());
        userHerbApprove.setAddTime(LocalDateTime.now());
        userHerbApprove.setUpdateTime(LocalDateTime.now());
        userHerbAuthMapper.insertSelective(userHerbApprove);
    }

}
